package com.rongc.client.freight.business.mine.view.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.flyco.dialog.listener.OnBtnClickL;
import com.flyco.dialog.widget.NormalDialog;
import com.rongc.client.core.utils.ActivityUtils;
import com.rongc.client.core.utils.StringUtils;
import com.rongc.client.freight.R;
import com.rongc.client.freight.UniApplication;
import com.rongc.client.freight.base.BaseActivity;
import com.rongc.client.freight.base.view.widget.DividerItemDecoration;
import com.rongc.client.freight.business.mine.model.WalletBean;
import com.rongc.client.freight.business.mine.view.adapter.RecyclerWalletAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;

import static com.flyco.dialog.widget.NormalDialog.STYLE_TWO;

/**
 * Created by ccqx on 2017/7/17.
 */

public class MineWalletActivity extends BaseActivity implements View.OnClickListener{
    @Bind(R.id.recycler)
    RecyclerView mRecyclerView;
    RecyclerWalletAdapter modelAdapter;

    List<WalletBean> datas;
    NormalDialog dialog ;

    @OnClick({R.id.lyt_tixian,R.id.lyt_yhq})
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.lyt_tixian:
                dialog.show();
                break;
            case R.id.lyt_yhq:
                break;
        }

    }

    @Override
    public void initView() {
        initToolbar(R.string.wallet_title);

        datas = new ArrayList<>();
        datas.add(new WalletBean("+100","2017-05-05 10:34","收入"));
        datas.add(new WalletBean("+100","2017-05-05 10:34","收入"));
        datas.add(new WalletBean("+100","2017-05-05 10:34","收入"));
        modelAdapter = new RecyclerWalletAdapter(this,datas);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
        mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
        mRecyclerView.setAdapter(modelAdapter);

        dialog = new NormalDialog(this);
        dialog.content("请设置支付密码")
                .style(STYLE_TWO)
                .btnText(new String[]{"取消","设置"})
                .setOnBtnClickL(new OnBtnClickL() {
                    @Override
                    public void onBtnClick() {
//                        ActivityUtils.startActivity(MineWalletActivity.this,PasswordPayActivity.class);
                        dialog.cancel();
                    }
                },new OnBtnClickL() {
                    @Override
                    public void onBtnClick() {
                        if(StringUtils.isEmpty(UniApplication.getInstance().getUserInfo().getPassword()))
                            ActivityUtils.startActivity(MineWalletActivity.this,PasswordPayActivity.class);
                        else
                            ActivityUtils.startActivity(MineWalletActivity.this,TixianActivity.class);

                    }
                });
    }


    @Override
    public int getLayoutId() {
        return R.layout.activity_wallet_host;
    }
}
